package cn.itcast.servlet;

import cn.itcast.service.CustomerService;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DeleteServlet
  extends HttpServlet
{
  private static final long serialVersionUID = -1425911876196761538L;
  
  public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
  {
    String id = request.getParameter("id");
    
    CustomerService cs = new CustomerService();
    
    int count = cs.delete(id);
    if (count == 1) {
      response.sendRedirect(request.getContextPath() + "/listCustomer");
    }
  }
  
  public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
  {
    doGet(request, response);
  }
}
